<template>
  <div>
    <Header :left="true" leftText="返回" title="设备维修--塑胶" />

    <!-- 滑动区域，适应手机分辨率 -->
    <div class="textScroll">
      <div>
        <van-row>
          <van-col>
            <van-image
              width="40"
              height="30"
              style="margin-left: -10px"
              src="assets/block.png"
            />
          </van-col>
          <van-col class="message">多媒体信息</van-col>
        </van-row>
      </div>
      <!-- 多媒体信息 -->
      <div class="divMedia">
        <van-row style="margin-top: 10px">
          <van-col
            span="4"
            style="
              font-weight: bold;
              color: #a9a9a9;
              margin-left: 10px;
              margin-top: 8px;
            "
            >视频：</van-col
          >
          <van-col span="14" style="color: #a9a9a9">
            <!-- 循环显示视频 -->
            <div
              v-show="vedioShow"
              v-for="item in vedioList"
              :key="item.id"
              style="margin-left: -10px"
            >
              <van-image
                style="float: left"
                width="50"
                height="40"
                @click="playVedio(item.filePath)"
                src="assets/vedio.png"
              />
            </div>
          </van-col>
        </van-row>
        <van-divider style="margin-top: 0px" />
        <van-row style="margin-top: 10px">
          <van-col
            span="4"
            style="
              font-weight: bold;
              color: #a9a9a9;
              margin-left: 10px;
              margin-top: 8px;
            "
            >照片：</van-col
          >
          <van-col span="14" style="color: #a9a9a9">
            <van-uploader
              v-show="photoShow"
              v-model="photoList"
              :deletable="false"
              multiple
              :max-count="pictureNum"
            />
          </van-col>
        </van-row>
        <van-divider style="margin-top: 0px" />
        <van-row style="margin-top: 10px">
          <van-col
            span="4"
            style="
              font-weight: bold;
              color: #a9a9a9;
              margin-left: 10px;
              margin-top: 8px;
            "
            >语音：</van-col
          >
          <van-col span="14" style="color: #a9a9a9">
            <div
              v-show="audioShow"
              @click="playArm"
              style="
                background-color: #00ff33;
                width: 140px;
                height: 35px;
                margin-left: -10px;
              "
            >
              <van-image
                v-show="audioStop"
                width="40"
                height="30"
                style="margin-right: 3px; float: left"
                src="assets/voice.png"
              >
              </van-image>
              <van-loading
                v-show="audioLoad"
                style="float: center"
                color="white"
                ><span style="color: white; font-size: 15px"
                  >播放中...</span
                ></van-loading
              >
            </div>
          </van-col>
        </van-row>
      </div>
      <div>
        <van-row style="margin-top: 10px">
          <van-col>
            <van-image
              width="40"
              height="30"
              style="margin-left: -10px"
              src="assets/block.png"
            />
          </van-col>
          <van-col class="message">维修后取证</van-col>
        </van-row>
      </div>
      <Field
        v-model="equipRepairVo.remark"
        size="large"
        rows="1"
        autosize
        label="维修后描述"
        type="textarea"
        maxlength="50"
        placeholder="请输入维修后描述"
        show-word-limit
      />
      <div ref="divMedia2" class="divMedia2">
        <Field
          :readonly="true"
          name="checkres"
          @click="showCamera"
          label="点击拍照上传"
          placeholder="————点击拍照————"
          right-icon="assets/right.png"
        />
        <div
          v-if="
            equipRepairVo.picList !== undefined &&
            equipRepairVo.picList.length > 0
          "
        >
          <div
            style="margin-left: 15px"
            v-for="(imgUrl, ks) in equipRepairVo.picList"
            :key="ks"
          >
            <div class="van-uploader__wrapper" style="float: left">
              <div class="van-uploader__preview">
                <div
                  @click="picShow(ks)"
                  class="van-image van-uploader__preview-image"
                >
                  <img :src="imgUrl" class="van-image__img" />
                </div>
                <div
                  class="van-uploader__preview-delete"
                  @click="delObj('pic', imgUrl)"
                >
                  <i
                    class="van-icon van-icon-cross van-uploader__preview-delete-icon"
                  ></i>
                </div>
              </div>
            </div>
          </div>
        </div>
        <Field name="checkres" label="视频拍摄">
          <template #input>
            <Button
              class="mg5"
              icon="play-circle"
              plain
              round
              hairline
              size="small"
              type="primary"
              @click="startVideoRecord"
              >录制</Button
            >
          </template>
        </Field>
        <div
          v-if="
            equipRepairVo.videoList !== undefined &&
            equipRepairVo.videoList.length > 0
          "
        >
          <div
            class="van-uploader"
            v-for="(videoUrl, index) in equipRepairVo.videoList"
            :key="index"
          >
            <div class="van-uploader__wrapper">
              <div class="van-uploader__preview">
                <div @click="showVideo(videoUrl)" class="tag_margin">
                  <Tag plain size="large" type="danger"
                    >视频文件{{ index + 1 }}</Tag
                  >
                </div>
                <div
                  class="van-uploader__preview-delete"
                  @click="delObj('video', videoUrl)"
                >
                  <i
                    class="van-icon van-icon-cross van-uploader__preview-delete-icon"
                  ></i>
                </div>
              </div>
            </div>
          </div>
        </div>
        <Field name="checkres" label="录制语音">
          <template #input>
            <Button
              class="mg5"
              plain
              round
              hairline
              icon="volume"
              size="small"
              type="warning"
              :loading="btnLoading"
              loading-text="正在播放"
              @touchstart.native="recordAudio"
              @touchend.native="stopRecordAudio"
              >按住说话</Button
            >
          </template>
        </Field>
        <div
          v-if="
            equipRepairVo.audioList !== undefined &&
            equipRepairVo.audioList.length > 0
          "
        >
          <div
            class="van-uploader"
            v-for="(audioUrl, adIndex) in equipRepairVo.audioList"
            :key="adIndex"
          >
            <div class="van-uploader__wrapper">
              <div class="van-uploader__preview">
                <div @click="showAudio(audioUrl)" class="tag_margin">
                  <Tag plain size="large" type="success"
                    >语音文件{{ adIndex + 1 }}</Tag
                  >
                </div>
                <div
                  class="van-uploader__preview-delete"
                  @click="delObj('audio', audioUrl)"
                >
                  <i
                    class="van-icon van-icon-cross van-uploader__preview-delete-icon"
                  ></i>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 文字信息 -->
      <van-row style="margin-top: 10px">
        <van-col>
          <van-image
            width="40"
            height="30"
            style="margin-left: -10px"
            src="assets/block.png"
          />
        </van-col>
        <van-col class="message" style="margin-top: 5px">文字信息</van-col>
      </van-row>

      <div class="divMessage">
        <Field
          v-model="form.repairCode"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="维修编号"
        />
        <Field
          v-model="form.remark"
          rows="1"
          autosize
          style="font-weight: bold; color: #a9a9a9"
          :readonly="true"
          label="报修描述"
          type="textarea"
        />
        <Field
          v-model="form.equipName"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="设备编码"
        />
        <Field
          v-model="form.equipDesc"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="设备名称"
        />
        <Field
          v-model="form.requestUser"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="报修人"
        />
        <Field
          v-model="form.requestTime"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="报修时间"
        />
        <Field
          v-model="helpUserNameStr"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          placeholder="————选择协助人————"
          @click="openSelectUser"
          right-icon="assets/right.png"
          label="协助人"
        />
        <Field
          v-model="faultType"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          placeholder="————选择故障类型————"
          @click="faultShowPicker = true"
          right-icon="assets/right.png"
          label="故障类型"
        />
        <Field
          v-model="sparePartContent"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          placeholder="————选择备件————"
          right-icon="assets/right.png"
          label="备件记录"
        />
      </div>
    </div>

    <!-- 底部按钮 -->
    <van-row class="button" gutter="3">
      <van-col span="2">
        <van-button
          :block="true"
          class="buttonColor2"
          type="primary"
          text="<<"
        />
      </van-col>
      <van-col span="6">
        <van-button
          :block="true"
          @click="startRepair"
          :disabled="btnStartShow"
          class="buttonColor2"
          type="primary"
          text="开始维修"
        />
      </van-col>
      <van-col span="6">
        <van-button
          :block="true"
          class="buttonColor"
          @click="stopRepair"
          :disabled="btnStopShow"
          type="primary"
          text="维修暂停"
        />
      </van-col>
      <van-col span="6">
        <van-button
          :block="true"
          class="buttonColor2"
          @click="finishRepair"
          :disabled="btnEndShow"
          type="primary"
          text="结束维修"
        />
      </van-col>
      <van-col span="2">
        <van-button
          :block="true"
          class="buttonColor2"
          type="primary"
          text=">>"
        />
      </van-col>
    </van-row>
    <!-- 故障类型弹窗 -->
    <van-popup v-model="faultShowPicker" round position="bottom">
      <van-picker
        showPicker="false"
        title="故障类型选择"
        value-key="text"
        show-toolbar
        @confirm="faultOnConfirm"
        :columns="faultTypes"
        @cancel="faultShowPicker = false"
        default-index="0"
      />
    </van-popup>

    <!-- 暂停原因 -->
    <van-popup v-model="resonShow" round position="bottom">
      <van-picker
        showPicker="false"
        title="暂停原因选择"
        value-key="text"
        show-toolbar
        @confirm="resonConfirm"
        :columns="stopReson"
        @cancel="resonShow = false"
        default-index="0"
      />
    </van-popup>
  </div>
</template>
<script>
import {
  Icon,
  NoticeBar,
  Button,
  Row,
  Tag,
  Checkbox,
  Pagination,
  popup,
  Loading,
  Popup,
  Panel,
  ImagePreview,
  Toast,
  tab,
  tabs,
  Divider,
  Image as VanImage,
  Field,
  CellGroup,
  Cell,
  Picker,
  Uploader,
  Dialog,
  Col,
} from "vant";
import { _httpClient } from "@/libs/api";
import { storage } from "@/libs/utils";
import {
  removeToken,
  getToken,
  setBaseApiFrefix,
  getBaseApiFrefix,
} from "@/libs/auth";
Vue.use(Cell);
Vue.use(CellGroup);
Vue.use(tab);
Vue.use(tabs);
Vue.use(Button);
Vue.use(Col);
Vue.use(Row);
Vue.use(Icon);
Vue.use(VanImage);
Vue.use(Divider);
Vue.use(Checkbox);
Vue.use(Pagination);
Vue.use(Panel);
Vue.use(Dialog);
Vue.use(Picker);
Vue.use(popup);
Vue.use(Uploader);
Vue.use(Loading);
import Header from "@/components/header.vue";
import apicloud from "@/libs/apicloud";
export default {
  name: "repairplus",
  components: {
    Button,
    NoticeBar,
    Header,
    ImagePreview,
    Icon,
    Row,
    tab,
    popup,
    Popup,
    tabs,
    Tag,
    VanImage,
    Toast,
    Divider,
    Field,
    CellGroup,
    Cell,
    Uploader,
    Picker,
    Dialog,
    Col,
  },

  data() {
    return {
      btnLoading: false,
      winName: "", //窗口名
      user: [], //当前登录用户
      //多媒体文件
      photoList: [
        //图片
      ],
      pictureNum: 0, //照片数量
      playing: "播放中...", //语音播放中字幕
      audioLoad: false, // 语音播放中
      audioStop: true, // 语音暂停
      photoShow: false, //照片显示控制
      vedioShow: false, //视频显示控制
      audioShow: false, //语音显示控制
      vedioList: [], //视频
      audioPath: "", //语音
      resonShow: false, //暂停原因录入弹窗是否显示
      btnStartShow: false, //开始维修按钮权限
      btnAssignShow: true, //任务转派按钮权限
      btnStopShow: true, //维修暂停按钮权限
      btnEndShow: true, //维修结束按钮权限
      stopResonValue: "", //维修暂停原因

      equipRepairVo: {
        id: null,
        eqKey: null,
        equipName: "",
        equipCode: "",
        remark: null,
        picList: [],
        videoList: [],
        audioList: [],
        resTime: null,
        requestUser: "",
        repairReson: "",
      },
      faultShowPicker: false, //故障原因下拉框
      screenWidth: 0,
      checked: true,
      active: 2,
      helpUser: [], //协助人
      helpUserStr: "", //协助人拼接字符串
      helpUserNameStr: "", //协助人拼接字符串
      helpUserContent: "", //协助人拼接字段
      faultType: "", //故障类型
      sparePart: [], //备件记录
      sparePartContent: "", //备件拼接字段
      fileUrl: "",
      form: [],
      faultTypes: [],
      stopReson: [],
      uploadSuccess: false,
    };
  },
  created: function () {
    let oldHight = api.winWidth;
    this.screenWidth = oldHight;
    this.user = JSON.parse(storage.get("user"));
    // this.equipRepairVo.resTime = this.getNowTime()
    api.requestPermission(
      {
        list: ["camera", "microphone", "storage"],
      },
      function (ret, err) {}
    );

    let tkn = getToken();
    if (!tkn) {
      api.openWin({
        name: "login",
        url: "./login-login.html",
        rect: {
          x: 0,
          y: 150,
          w: api.winWidth,
          h: api.winHeight,
        },
      });
    }
    //页面赋值
    this.initdata();
  },
  methods: {
    async initdata() {
      let _this = this;
      try {
        let res = await _httpClient.post(
          _httpClient.getApiPrefix() +
            "/app/repair/repairInfo/wiatExecutelistbyCode",
          {
            body: {
              id: _this.result,
            },
          }
        );
        if (res.code === 200) {
          _this.form = res.Rows[0];
          _this.equipRepairVo.id = _this.form.id;
          _this.refreshBtn();
          //初始化查询维修协助人
          _this.queryHelpUser();
          //初始化查询多媒体信息
          _this.queryFileById();
          //初始化查询故障信息
          _this.queryEmFault();
          //初始化查询维修暂停原因
          _this.queryEmStopReson();
        } else {
          Toast.fail(res.msg);
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //视频播放
    playVedio(filePath) {
      let that = this;
      if (
        api.deviceName.toLowerCase() == "vivo" ||
        api.deviceName.toLowerCase() == "oppo" ||
        api.deviceName.toLowerCase() == "honor"
      ) {
        var videoPlayer = api.require("videoPlayer");
        videoPlayer.play(
          {
            path: filePath.trim(),
            autoPlay: true,
          },
          function (ret, err) {}
        );
      } else {
        that.$ac.openVideo({
          url: filePath.trim(),
        });
      }
    },

    //语音播放
    playArm() {
      //判断是播放还是暂停
      if (!this.audioLoad) {
        this.audioLoad = true;
        this.audioStop = false;
        if (this.audioPath == "") {
          Dialog.alert({
            message: "当前无语音信息",
            theme: "round-button",
          }).then(() => {
            // on close
          });
        }
        var audioStreamer = api.require("audioStreamer");
        let _this = this;
        audioStreamer.addEventListener({}, function (ret) {
          if (ret.state == "finished") {
            _this.audioLoad = false;
            _this.audioStop = true;
          }
        });
        if (api.systemType == "ios") {
          api.download(
            {
              url: _this.audioPath,
            },
            function (res) {
              if (res.state == 1) {
                api.startPlay(
                  {
                    path: res.savePath,
                  },
                  function (ret, err) {
                    if (ret) {
                      // _that.activeAudio = ''
                    } else {
                      alert(JSON.stringify(err));
                    }
                  }
                );
              }
            }
          );
        } else {
          audioStreamer.openPlayer(
            {
              path: _this.audioPath,
            },
            function (ret) {}
          );
        }
      } else {
        var audioStreamer = api.require("audioStreamer");
        audioStreamer.pause();
        this.audioLoad = false;
        this.audioStop = true;
      }
    },

    picShow(pIndex) {
      ImagePreview({
        images: this.equipRepairVo.picList || [],
        showIndicators: true,
        startPosition: pIndex || 0,
        showIndex: false,
      });
    },
    showCamera() {
      let that = this;
      //alert("手机系统"+api.deviceName.toLowerCase());
      //判断设备系统类型
      if (api.systemType == "ios") {
        that.iosCamera();
      } else {
        if (api.deviceName.toLowerCase() == "vivo") {
          that.vivoCamera();
        } else if (api.deviceName.toLowerCase() == "oppo") {
          that.oppoReno2Camera();
        } else if (api.deviceName.toLowerCase() == "oneplus") {
          that.oppoReno2Camera();
        } else if (api.deviceName.toLowerCase() == "honor") {
          that.vivoCamera();
        } else if (api.deviceName.toLowerCase() == "xiaomi") {
          that.vivoCamera();
        } else if (api.deviceName.toLowerCase() == "meizu") {
          that.vivoCamera();
        } else if (api.deviceName.toLowerCase() == "realme") {
          that.vivoCamera();
        } else if (api.deviceName.toLowerCase() == "huawei") {
          that.vivoCamera();
          // that.otherCamera();
          // that.otherCameraPlus();
        } else if (api.deviceName.toLowerCase() == "ptac") {
          that.vivoCamera();
        } else { 
          that.vivoCamera();
          // that.otherCameraPlus();
          // that.otherCamera();
        }
        // var phoneInfo = api.require('phoneInfo')
        // phoneInfo.getBaseInfo(function(ret, err) {
        //   if (ret.status) {
        //     if (ret.brand == 'vivo') {
        //       // that.vivoCamera()
        //       that.iosCamera()
        //     } else if (ret.brand == 'oppo') {
        //       that.oppoReno2Camera()
        //     } else {
        //       that.otherCamera()
        //     }
        //   } else {
        //     api.alert({ msg: err.msg })
        //   }
        // })
      }
    },

    vivoCamera() {
      let that = this;
      var FNPhotograph = api.require("FNPhotograph");
      FNPhotograph.open(
        {
          album: false,
          quality: "high",
          isShowAlbum: false,
          // useAdvanceFeature: true,
          // pictureSize: '2075x1080',
          // previewSize: '2075x1080',
        },
        function (ret) {
          if (ret && ret.eventType == "takePhoto") {
            let imgSrc = ret.imagePath;
            if (imgSrc && imgSrc != "") {
              FNPhotograph.close();
              that.imageFilter(imgSrc);
            }
          }
        }
      );
    },

    oppoReno2Camera() {
      let _this = this;
      api.getPicture(
        {
          sourceType: "camera",
          encodingType: "jpg",
          mediaValue: "pic",
          allowEdit: false,
          destinationType: "url",
          quality: 50,
        },
        function (ret, err) {
          // 获取拍照数据并处理
          if (ret) {
            let imgSrc = ret.data;
            if (imgSrc && imgSrc != "") {
              _this.imageFilter(imgSrc);
            }
          }
        }
      );
    },

    otherCamera() {
      let that = this;
      // var cameraTool = api.require('cameraTool')
      // cameraTool.openCamera(function(ret, err) {
      //   let imgPath = ret.imgPath
      //   if (imgPath && imgPath != '') {
      //     that.imageFilter(imgPath)
      //   }
      // })
      var module = api.require("easyCamera");
      var param = {
        typeString: "image", // 或者'video-20'
      };
      var resultCallback = function (ret, err) {
        var msg = ret.msg;
        if (msg && msg != "") {
          that.imageFilter(msg);
        }
      };
      module.openCamera(param, resultCallback);
    },
    otherCameraPlus() {
      let that = this;
      var ox = api.require("oxWxRecorder");
      ox.getPermission(function (ret) {
        var code = ret.code;
        if (code == 1) {
          ox.open(
            {
              fixedOn: api.frameName,
              rect: { x: 0, y: 0, w: w, h: h },
              fixed: true,
              type: 2, //0拍照录像 1 录像 2 拍照
            },
            function (ret1) {
              var code1 = ret1.code;
              if (code1 == 0) {
                //关闭事件
              } else if (code1 == 2) {
                //返回图片路径path
                that.imageFilter(ret1.path);
              } else if (code1 == -1) {
                //错误信息
                alert(ret1.text);
              }
            }
          );
        }
      });
    },
    xiaomiCamera() {
      let that = this;
      var cameraTool = api.require("cameraTool");
      cameraTool.openCamera(function (ret, err) {
        let imgPath = ret.imgPath;
        if (imgPath && imgPath != "") {
          that.imageFilter(imgPath);
        }
      });
    },
    iosCamera() {
      let that = this;
      let zySmallVideo = api.require("zySmallVideo");
      zySmallVideo.openNew(
        {
          rect: {
            //模块 附于一个frame之上
            x: 0,
            y: 0,
            w: api.frameWidth,
            h: api.frameHeight,
          },
          fixedOn: api.frameName,
          fixed: true,
          videoInfo: {
            setOutputFormat: 2, //录制格式 默认2 mp4  0（DEFAULT） 1（THREE_GPP） 2（MPEG_4默认） 3（RAW_AMR） 4（AMR_WB） 5（AAC_ADIF） 6（AAC_ADTS） 7（OUTPUT_FORMAT_RTP_AVP） 8（OUTPUT_FORMAT_MPEG2TS） 9（WEBM）
            setVideoEncoder: 2, //编码格式 默认2 h264 0（DEFAULT） 1（H263） 2（H264默认） 3（MPEG_4_SP） 4（VP8） 5（HEVC）
            setAudioEncoder: 3, //音频格式应该是 默认3 aac  0（DEFAULT） 1（AMR_NB） 2（AMR_WB） 3（AAC默认） 4（HE_AAC） 5（AAC_ELD） 6（VORBIS）
          },
          MaxRecordTime: 60, //最大录制时间 单位秒 默认10
          MinRecordTime: 5, //最短录制时间  单位s
          MinTimeText: "时间不能小于5秒，不能大于60秒", //最短时间提示词
          setFeatures: 1001, //设置拍照和录像   1001只拍照   1002只录像   1003两者都可以  默认1003
          setTip: "", //设置按钮上的提示词   长按拍摄等 默认空
          setBackIcon: "", //自定义返回图标 默认向下键头  支持widget  fs 等路径图片
          setBackShow: 1, //设置返回图标是否显示 1是 0否  默认1
          setCameraIcon: "", //自定义切换摄像头图标  支持widget  fs 等路径图片
          setCameraShow: 1, //右上角切换摄像头是否显示 1是 0否 默认1
          cameraInfo: {
            //摄像头 设置样式
            fit_xy: false, //图片是否拉伸占满宽高  默认false
            margin_l: 0, //距左 默认都是0
            margin_r: 35, //距右
            margin_t: 65, //距上
            margin_b: 0, //距下
          },
          foucsInfo: {
            //点击的对焦框 样式
            color: "#cd0000", //线条颜色 默认16AE16
            width: 4, //线条宽度 默认4
          },
          recordInfo: {
            progress_color: "#cd0000", //进度条颜色 默认16AE16
            outside_color: "#DCDCDC", //外圆背景色 默认DCDCDC
            inside_color: "#FFFFFF", //内圆背景色 默认FFFFFF
          },
          confirmInfo: {
            //确认框参数
            fit_xy: false, //图片是否拉伸占满宽高  默认false
            img: "", //设置自定义图片
          },
          cancelInfo: {
            //取消框参数
            fit_xy: false, //图片是否拉伸占满宽高  默认false
            img: "", //设置自定义图片
          },
        },
        function (ret, err) {
          if (ret.status) {
            if (ret.type == "captureSuccess") {
              that.imageFilter(ret.result);
            }
          }
        }
      );
    },

    //图片压缩
    imageFilter(imgPath) {
      let that = this;
      var imageFilter = api.require("imageFilter");
      var imageCachePath = api.cacheDir; //cache://协议对应的真实目录，字符串类型
      imageFilter.compress(
        {
          img: imgPath,
          quality: 0.5,
          size: "800X600",
          save: {
            album: false,
            imgPath: imageCachePath + "/",
            imgName: "cs.jpg",
          },
        },
        function (ret, err) {
          let imgUrl = imageCachePath + "/cs.jpg";
          that.getFileName("pic", imgUrl);
          //文件删除
          var fs = api.require("fs");
          fs.remove(
            {
              path: imgPath,
            },
            function (ret, err) {
              if (ret.status) {
              } else {
              }
            }
          );
        }
      );
    },

    recordAudio() {
      this.$ac.showProgress({
        title: "录制中...",
        text: "释放手指结束录音...",
        modal: false,
      });
      //开始录音
      this.$ac.startRecord({
        // path: 'fs://audio.amr',
        path: "fs://audio.aac",
        format: "aac",
      });
    },
    stopRecordAudio() {
      let that = this;
      that.$ac.hideProgress();
      that.$ac.stopRecord(function (ret, err) {
        if (ret) {
          if (that.equipRepairVo.audioList.length == 0) {
            let nowHeight = that.$refs.divMedia2.offsetHeight;
            that.$refs.divMedia2.style.height = nowHeight + 40 + "px";
          }
          that.getFileName("audio2", ret.path);
        }
      });
    },

    //获取文件名称
    async getFileName(fType, fUrl) {
      let type = "jpg";
      if (fType === "audio") {
        type = "amr";
      } else if (fType === "video") {
        type = "mp4";
      } else if (fType === "pic") {
        type = "jpg";
      } else if (fType === "audio2") {
        type = "aac";
      }
      let res = await _httpClient.get(
        _httpClient.getApiPrefix() + "/minio/oss/getFileName?fileType=" + type
      );
      if (res.code === 200) {
        //上传文件
        this.putObj(fType, fUrl, res.fileName);
      }
    },

    //定时器
    timeCycle(fType, fileName) {
      let that = this;
      let cycleNum = 0;
      that.uploadSuccess = false;
      let intervald = setInterval(() => {
        if (
          that &&
          !that._isDestroyed &&
          cycleNum < _httpClient.getUploadCycle() &&
          !that.uploadSuccess
        ) {
          setTimeout(() => {
            if (that && !that._isDestroyed) {
              that.queryFileUpload(fType, fileName);
              cycleNum++;
            }
          }, 0);
        } else {
          //清除定时器
          clearInterval(intervald);
          that.uploadSuccess = true;
          Toast.clear();
          if (cycleNum == _httpClient.getUploadCycle()) {
            alert("上传超时，请重试");
          }
        }
      }, 2000);
    },

    //查询文件是否上传成功
    async queryFileUpload(fType, fileName) {
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "校验保存中...",
      });
      let that = this;
      let res = await _httpClient.get(
        _httpClient.getApiPrefix() + "/minio/oss/" + fileName
      );
      if (res.code === 200) {
        let urls = res.objectURL.split("?");
        if (urls.length > 0) {
          Toast("上传成功");
          let nowHeight = that.$refs.divMedia2.offsetHeight;
          if (fType === "audio") {
            that.equipRepairVo.audioList.push(urls[0]);
          } else if (fType === "video") {
            that.equipRepairVo.videoList.push(urls[0]);
            if (that.equipRepairVo.videoList.length == 1) {
              that.$refs.divMedia2.style.height = nowHeight + 10 + "px";
            } else if (that.equipRepairVo.videoList.length == 5) {
              that.$refs.divMedia2.style.height = nowHeight + 10 + "px";
            } else if (that.equipRepairVo.videoList.length == 9) {
              that.$refs.divMedia2.style.height = nowHeight + 10 + "px";
            }
          } else if (fType === "pic") {
            that.equipRepairVo.picList.push(urls[0]);
            if (that.equipRepairVo.picList.length == 1) {
              that.$refs.divMedia2.style.height = nowHeight + 60 + "px";
            } else if (that.equipRepairVo.picList.length == 5) {
              that.$refs.divMedia2.style.height = nowHeight + 70 + "px";
            } else if (that.equipRepairVo.picList.length == 9) {
              that.$refs.divMedia2.style.height = nowHeight + 60 + "px";
            }
          } else if (fType === "audio2") {
            that.equipRepairVo.audioList.push(urls[0]);
          }
        }
        Toast.clear();
        that.uploadSuccess = true;
      }
    },

    //文件上传
    putObj(fType, fUrl, fileName) {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "上传中...0%",
      });
      api.ajax(
        {
          url:
            _httpClient.getApiPrefix() +
            "/minio/oss/appPutObject?fileName=" +
            fileName,
          //  url: 'http://192.168.2.102:8083' + '/minio/oss/putObject',
          method: "post",
          headers: {
            Authorization: "Bearer " + getToken(),
          },
          report: true,
          data: {
            files: {
              file: fUrl,
            },
          },
        },
        function (ret, err) {
          if (ret) {
            Toast.loading({
              mask: true,
              forbidClick: true,
              duration: 0,
              message: "上传进度...\n" + ret.progress + "%",
            });
            if (ret.body.code === 200) {
              if (api.systemType == "ios") {
                _this.timeCycle(fType, fileName);
                //文件删除
                var fs = api.require("fs");
                fs.remove(
                  {
                    path: fUrl,
                  },
                  function (ret, err) {
                    if (ret.status) {
                    } else {
                    }
                  }
                );
              }
            } else if (ret.progress == 100) {
              _this.timeCycle(fType, fileName);
              //文件删除
              var fs = api.require("fs");
              fs.remove(
                {
                  path: fUrl,
                },
                function (ret, err) {
                  if (ret.status) {
                  } else {
                  }
                }
              );
            }
          } else {
            Toast.clear();
          }
        }
      );
    },

    // async putObj(fType, fUrl) {
    //   let _this = this
    //   Toast.loading({
    //     mask: true,
    //     forbidClick: true,
    //     duration: 0,
    //     message: '请稍等...',
    //   })
    //   try {
    //     let res = await _httpClient.postFile(_httpClient.getApiPrefix() + '/minio/oss/putObject', {
    //       files: {
    //         file: fUrl,
    //       },
    //     })
    //     if (res.code === 200) {
    //       if (res.fileUrl) {
    //         Toast.clear()
    //         if (fType === 'audio') {
    //           _this.equipRepairVo.audioList.push(res.fileUrl)
    //         } else if (fType === 'video') {
    //           _this.equipRepairVo.videoList.push(res.fileUrl)
    //         } else if (fType === 'pic') {
    //           _this.equipRepairVo.picList.push(res.fileUrl)
    //         }
    //       }
    //     }
    //   } catch (e) {
    //     Toast.fail(JSON.stringify(e))
    //   }
    // },
    showAudio(audioUrl) {
      let that = this;
      if (!audioUrl) {
        Toast("没有要播放的文件");
        return;
      }
      that.btnLoading = true;

      let audioStreamer = api.require("audioStreamer");
      let _this = this;
      audioStreamer.addEventListener({}, function (ret) {
        if (ret.state == "finished") {
          that.btnLoading = false;
        }
      });
      if (api.systemType == "ios") {
        api.download(
          {
            url: audioUrl,
          },
          function (res) {
            if (res.state == 1) {
              api.startPlay(
                {
                  path: res.savePath,
                },
                function (ret, err) {
                  if (ret) {
                    // _that.activeAudio = ''
                  } else {
                    alert(JSON.stringify(err));
                  }
                }
              );
            }
          }
        );
      } else {
        audioStreamer.openPlayer(
          {
            path: audioUrl,
          },
          function (ret) {}
        );
      }
    },
    // 取消
    concel() {
      api.closeWin();
    },

    startVideoRecord() {
      if (api.systemType == "ios") {
        let that = this;
        let zySmallVideo = api.require("zySmallVideo");
        zySmallVideo.openNew(
          {
            rect: {
              //模块 附于一个frame之上
              x: 0,
              y: 0,
              w: api.frameWidth,
              h: api.frameHeight,
            },
            fixedOn: api.frameName,
            fixed: true,
            videoInfo: {
              //视频高级设置 不懂请勿修改
              //videoSize_w:720,//视频分辨率 宽 默认720
              //videoSize_h:1280,//视频分辨率 高 默认1280
              setOutputFormat: 2, //录制格式 默认2 mp4  0（DEFAULT） 1（THREE_GPP） 2（MPEG_4默认） 3（RAW_AMR） 4（AMR_WB） 5（AAC_ADIF） 6（AAC_ADTS） 7（OUTPUT_FORMAT_RTP_AVP） 8（OUTPUT_FORMAT_MPEG2TS） 9（WEBM）
              setVideoEncoder: 2, //编码格式 默认2 h264 0（DEFAULT） 1（H263） 2（H264默认） 3（MPEG_4_SP） 4（VP8） 5（HEVC）
              setAudioEncoder: 3, //音频格式应该是 默认3 aac  0（DEFAULT） 1（AMR_NB） 2（AMR_WB） 3（AAC默认） 4（HE_AAC） 5（AAC_ELD） 6（VORBIS）
            },
            MaxRecordTime: 60, //最大录制时间 单位秒 默认10
            MinRecordTime: 5, //最短录制时间  单位s
            MinTimeText: "时间不能小于5秒，不能大于60秒", //最短时间提示词
            setFeatures: 1002, //设置拍照和录像   1001只拍照   1002只录像   1003两者都可以  默认1003
            setTip: "", //设置按钮上的提示词   长按拍摄等 默认空
            setBackIcon: "", //自定义返回图标 默认向下键头  支持widget  fs 等路径图片
            setBackShow: 1, //设置返回图标是否显示 1是 0否  默认1
            setCameraIcon: "", //自定义切换摄像头图标  支持widget  fs 等路径图片
            setCameraShow: 1, //右上角切换摄像头是否显示 1是 0否 默认1
            cameraInfo: {
              //摄像头 设置样式
              fit_xy: false, //图片是否拉伸占满宽高  默认false
              //w:120,// 摄像头宽度 默认 120
              //h:92,// 摄像头高度 默认 92
              margin_l: 0, //距左 默认都是0
              margin_r: 35, //距右
              margin_t: 65, //距上
              margin_b: 0, //距下
            },
            foucsInfo: {
              //点击的对焦框 样式
              color: "#cd0000", //线条颜色 默认16AE16
              width: 4, //线条宽度 默认4
            },
            recordInfo: {
              //录制时的参数
              //button_radius:120,//外圆半径 默认120
              //button_inside_radius:90,//内圆半径 默认90
              progress_color: "#cd0000", //进度条颜色 默认16AE16
              outside_color: "#DCDCDC", //外圆背景色 默认DCDCDC
              inside_color: "#FFFFFF", //内圆背景色 默认FFFFFF
              //strokeWidth:15,//进度条宽度 默认15
              //outside_add_size:48,//长按外圆半径变大的Size 默认48
              //inside_reduce_size:30,//长按内圆缩小的Size 默认30
            },
            confirmInfo: {
              //确认框参数
              fit_xy: false, //图片是否拉伸占满宽高  默认false
              img: "", //设置自定义图片
              //w:220,//宽 默认200
              //h:220,//高 默认200
              //margin_r:170, //确认按距右
            },
            cancelInfo: {
              //取消框参数
              fit_xy: false, //图片是否拉伸占满宽高  默认false
              img: "", //设置自定义图片
              //w:220,//宽 默认200
              //h:220,//高 默认200
              //margin_l:170,//确认按距左
            },
          },
          function (ret, err) {
            if (ret.status) {
              // fileUrl = ret.fileUrl
              // document.getElementById('videoPic').src = ret.result
              if (ret.type == "recordSuccess") {
                that.getFileName("video", ret.url);
              }
            }
          }
        );
      } else {
        let that = this;
        let zySmallVideo = that.$ac.require("zySmallVideo");
        zySmallVideo.open(
          {
            MaxRecordTime: 60,
            MinRecordTime: 6, //最短录制时间  单位s
            MinTimeText: "时间不能小于5秒，不能大于60秒", //最短时间提示词
            videoColor: api.systemType == "ios" ? 0xcd0000 : "#cd0000",
            AVAssetExportPreset: "AVAssetExportPreset1280x720",
            mVideoSizeW: 720,
            mVideoSizeH: 1280,
          },
          function (ret, err) {
            if (ret.result == "success") {
              if (that.equipRepairVo.videoList.length == 0) {
                let nowHeight = that.$refs.divMedia2.offsetHeight;
                that.$refs.divMedia2.style.height = nowHeight + 40 + "px";
              }
              that.getFileName("video", ret.fileUrl);
            }
          }
        );
      }
    },
    showVideo(videoUrl) {
      let that = this;
      if (!videoUrl) {
        Toast("请先录制视频");
        return;
      }
      that.$ac.openVideo({
        url: videoUrl,
      });
    },
    zySmallVideoGetThumbnail() {
      let that = this;
      let zySmallVideo = that.$ac.require("zySmallVideo");
      if (!that.equip.videoUrl) {
        Toast("请先录制视频");
        return;
      }
      zySmallVideo.getThumbnail(
        {
          fileUrl: that.equip.videoUrl,
        },
        function (ret, err) {
          alert(JSON.stringify(ret));
          // document.getElementById('videoPic').src = ret.filePic;
        }
      );
    },
    async delObj(fType, fUrl) {
      this.btnLoading = false;
      let fname = "";
      try {
        if (fUrl != undefined && fUrl != "" && fUrl != null) {
          fname = fUrl.substring(fUrl.lastIndexOf("/") + 1);
        }
        let res = await _httpClient.delete(
          _httpClient.getApiPrefix() + "/minio/oss/" + fname
        );
        if (res.code === 200) {
          let flist = [];
          if (fType === "audio") {
            flist = this.equipRepairVo.audioList;
          } else if (fType === "video") {
            flist = this.equipRepairVo.videoList;
          } else if (fType === "pic") {
            flist = this.equipRepairVo.picList;
          }
          if (flist.length > 0) {
            for (var i = 0; i < flist.length; i++) {
              if (flist[i] == fUrl) {
                flist.splice(i, 1);
              }
            }
          }
          Toast.success(res.msg);
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },

    //维修暂停
    stopRepair() {
      Dialog.confirm({
        title: "提示",
        theme: "round-button",
        message: "是否确认暂停维修?",
      })
        .then(() => {
          //点击确定，继续执行后续操作
          //填写暂停原因
          this.resonShow = true;
          //操作后刷新界面按钮权限
          this.refreshBtn();
        })
        .catch(() => {});
    },

    //开始维修
    startRepair() {
      Dialog.confirm({
        title: "提示",
        theme: "round-button",
        message: "是否确认开始维修?",
      })
        .then(() => {
          //点击确定，继续执行后续操作
          this.updateRepairRcord();
          //操作后刷新界面按钮权限
          this.refreshBtn();
        })
        .catch(() => {});
    },

    //更新维修单
    async updateRepairRcord() {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.post(
          _httpClient.getApiPrefix() +
            "/app/repair/repairInfo/updateRepairStatus",
          {
            body: { id: _this.form.id },
          }
        );
        if (res.code === 200) {
          Toast.success(res.msg);
          _this.form.status = "1"; //更新维修单为执行中
          _this.refreshBtn();
        } else {
          Toast.fail(res.msg);
        }
      } catch (e) {
        alert(JSON.stringify(e));
        Toast.fail(JSON.stringify(e));
      }
    },

    //故障原因下拉框确认
    faultOnConfirm(value) {
      if (value[1] == null || value[1] == "") {
        this.faultType = String(value[0]);
      } else {
        this.faultType = String(value[1]);
      }

      this.faultShowPicker = false;
    },

    //协助人选择
    openSelectUser() {
      let _this = this;
      api.openWin({
        name: "helpUser",
        url: "./maintain-toRepair-helpUser.html",
        type: "fade",
        pageParam: {
          helpUser: _this.helpUser,
          recordId: _this.form.id,
        },
      });
      api.addEventListener(
        {
          name: "resultUser",
        },
        function (ret, err) {
          if (ret.value.resultUser.length != 0) {
            _this.helpUser = ret.value.resultUser;
            if (_this.helpUser.length > 0) {
              _this.helpUserStr = "";
              _this.helpUserNameStr = "";
              for (let i = 0; i < _this.helpUser.length; i++) {
                switch (i) {
                  case 0:
                    _this.helpUserStr += _this.helpUser[i].userCode;
                    _this.helpUserNameStr += _this.helpUser[i].userName;
                    break;
                  default:
                    //默认显示三个
                    if (i < 4) {
                      _this.helpUserStr += "、" + _this.helpUser[i].userCode;
                      _this.helpUserNameStr +=
                        "、" + _this.helpUser[i].userName;
                    }
                }
              }
            }
          }
        }
      );
    },

    //按钮权限刷新
    refreshBtn() {
      //校验当前维修单状态，初始化按钮点击权限
      switch (this.form.status) {
        case "0": //待维修
          this.btnStartShow = false;
          this.btnAssignShow = false;
          this.btnStopShow = true;
          this.btnEndShow = true;
          break;
        case "1": //维修中
          this.btnStartShow = true;
          this.btnAssignShow = true;
          this.btnStopShow = false;
          this.btnEndShow = false;
          break;
        case "2": //维修暂停
          this.btnStartShow = false;
          this.btnAssignShow = false;
          this.btnStopShow = true;
          this.btnEndShow = true;
          break;
        case "3": //维修完成
          this.btnStartShow = true;
          this.btnAssignShow = true;
          this.btnStopShow = true;
          this.btnEndShow = true;
          break;
        case "4": //维修不通过
          this.btnStartShow = false;
          this.btnAssignShow = false;
          this.btnStopShow = true;
          this.btnEndShow = true;
          break;
        case "5": //关闭
          this.btnStartShow = true;
          this.btnAssignShow = true;
          this.btnStopShow = true;
          this.btnEndShow = true;
          break;
        default:
          this.btnStartShow = false;
          this.btnAssignShow = false;
          this.btnStopShow = false;
          this.btnEndShow = false;
      }
    },

    //原因选择确认
    resonConfirm(value) {
      this.resonShow = false;
      this.stopResonValue = value.text;
      this.updateRepairStop();
    },
    //记录维修暂停
    async updateRepairStop() {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.post(
          _httpClient.getApiPrefix() +
            "/app/repair/repairRecordTime/updateRecordTime",
          {
            body: {
              recordId: _this.form.id,
              stopReson: _this.stopResonValue,
              type: 0,
            },
          }
        );
        if (res.code === 200) {
          Toast.success(res.msg);
          _this.form.status = "2"; //更新维修单为暂停
          _this.refreshBtn();
          if (_this.stopResonValue == "人员换班") {
            //任务转派
            _this.taskAssign();
          }
          _this.stopResonValue = "";
        } else {
          Toast.fail(res.msg);
        }
      } catch (e) {
        alert(JSON.stringify(e));
        Toast.fail(JSON.stringify(e));
      }
    },
    //维修完成
    async finishRepair() {
      let _this = this;
      if (_this.faultType == "") {
        Dialog.alert({
          theme: "round-button",
          message: "请选择故障类型",
        }).then(() => {
          // on close
        });
        return;
      }
      if (
        _this.equipRepairVo.audioList.length == 0 &&
        _this.equipRepairVo.videoList.length == 0 &&
        _this.equipRepairVo.picList.length == 0
      ) {
        Toast("请先拍照或录制视频或录制语音");
        return;
      }
      _this.btnLoading = true;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.post(
          _httpClient.getApiPrefix() + "/app/repair/repairInfo/finishRepair",
          {
            body: {
              recordId: _this.form.id,
              stopReson: _this.stopResonValue,
              faultType: _this.faultType,
              sparePart: _this.sparePart,
              finishTime: _this.getNowTime(),
              repairUser: _this.user.nickName,
              requestId: _this.form.requestId,
              siteKey: _this.user.site,
              remark: _this.equipRepairVo.remark,
            },
          }
        );
        //
        let res1 = await _httpClient.post(
          _httpClient.getApiPrefix() + "/app/repair/repairInfo/saveFile",
          {
            body: this.equipRepairVo,
          }
        );
        if (res.code === 200) {
          Dialog.alert({
            message: res.msg,
            theme: "round-button",
          }).then(() => {
            // on close
          });
          _this.form.status = "3"; //更新状态为维修完成
          //维修完成，关闭当前页面
          api.sendEvent({
            name: "result",
            extra: {
              item: _this.form,
            },
          });
          api.closeWin();
        } else {
          Toast.fail(res.msg);
        }
      } catch (e) {
        alert(JSON.stringify(e));
        Toast.fail(JSON.stringify(e));
      }
    },
    //任务转派
    taskAssign() {
      let _this = this;
      Dialog.confirm({
        title: "提示",
        message: "是否确认转派任务?",
        theme: "round-button",
      })
        .then(() => {
          //打开人员选择界面
          api.openWin({
            name: "personSelect",
            url: "./maintain-toRepair-personSelect.html",
            type: "fade",
          });
          api.addEventListener(
            {
              name: "resultUser",
            },
            function (ret, err) {
              if (ret.value.selectUser.length == 0) {
                Dialog.alert({
                  message: "未选择指派人员",
                  theme: "round-button",
                }).then(() => {
                  // on close
                });
                return;
              }
              let selectUser = ret.value.selectUser;
              //更新执行人
              _this.updateExecuter(_this.form.id, selectUser[0].userAccound);
            }
          );
        })
        .catch(() => {});
    },

    //更新执行人
    async updateExecuter(id, userName) {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.post(
          _httpClient.getApiPrefix() +
            "/app/repair/repairInfo/updateRepairUser",
          {
            body: { id: id, repairUser: userName },
          }
        );
        if (res.code === 200) {
          Toast.clear();
          api.sendEvent({
            name: "result",
            extra: {
              item: _this.form,
            },
          });
          _this.$ac.closeWin();
        } else {
          Toast.fail(res.msg);
        }
      } catch (e) {
        Toast.clear();
        alert(JSON.stringify(e));
      }
    },

    //查询维修单协助人
    async queryHelpUser() {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.post(
          _httpClient.getApiPrefix() + "/app/repair/repairInfo/selectHelpUser",
          {
            // body: { recordId: _this.form.id },
            body: { recordId: _this.form.id },
          }
        );
        if (res.code === 200) {
          Toast.clear();
          _this.helpUser = res.rows;
          if (_this.helpUser.length > 0) {
            for (let i = 0; i < _this.helpUser.length; i++) {
              switch (i) {
                case 0:
                  _this.helpUserStr += _this.helpUser[i].userCode;
                  _this.helpUserNameStr += _this.helpUser[i].userName;
                  break;
                default:
                  //默认显示三个
                  if (i < 4) {
                    _this.helpUserStr += "、" + _this.helpUser[i].userCode;
                    _this.helpUserNameStr += "、" + _this.helpUser[i].userName;
                  }
              }
            }
          }
        } else {
          Toast.fail(res.msg);
        }
      } catch (e) {
        Toast.clear();
        alert(JSON.stringify(e));
      }
    },

    //初始化查询故障信息
    async queryEmFault() {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.post(
          _httpClient.getApiPrefix() + "/app/repair/repairInfo/selectEmFault",
          {
            body: { siteKey: _this.user.site },
          }
        );
        if (res.code === 200) {
          Toast.clear();
          _this.faultTypes = res.rows;
        } else {
          Toast.fail(res.msg);
        }
      } catch (e) {
        Toast.clear();
        alert(JSON.stringify(e));
      }
    },

    //初始化查询维修暂停原因
    async queryEmStopReson() {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
            "/system/dict/data/type/sys_repair_stop_reson"
        );
        if (res.code === 200) {
          Toast.clear();
          if (res.data.length > 0) {
            for (let i = 0; i < res.data.length; i++) {
              let reson = { text: res.data[i].dictValue };
              _this.stopReson.push(reson);
            }
          } else {
            _this.stopReson = [];
          }
        } else {
          Toast.fail(res.msg);
        }
      } catch (e) {
        Toast.clear();
        alert(JSON.stringify(e));
      }
    },

    //查询维修单多媒体信息
    async queryFileById() {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.post(
          _httpClient.getApiPrefix() + "/app/repair/requestFile/selectFiles",
          {
            body: { requestId: _this.form.requestId },
          }
        );

        if (res.code === 200) {
          Toast.clear();
          if (res.rows.length > 0) {
            //筛选图片、视频、录音
            let pictures = [];
            let vedios = [];
            let audios = [];
            for (let i = 0; i < res.rows.length; i++) {
              if (res.rows[i].fileType == "0") {
                //照片
                let paths = res.rows[i].filePath.split(";");
                for (let j = 0; j < paths.length; j++) {
                  let num = 0;
                  if (paths[j] != "") {
                    let picture = { url: paths[j] };
                    pictures.push(picture);
                    num++;
                  }
                  _this.pictureNum = num;
                }
                //显示照片
                _this.photoShow = true;
              } else if (res.rows[i].fileType == "1") {
                let paths = res.rows[i].filePath.split(";");
                for (let j = 0; j < paths.length; j++) {
                  if (paths[j] != "") {
                    let vedio = { filePath: paths[j] };
                    _this.vedioList.push(vedio);
                  }
                }
                //视频
                // _this.vedioList.push(res.rows[i])
                _this.vedioShow = true;
              } else if (res.rows[i].fileType == "2") {
                //语音
                let paths = res.rows[i].filePath.split(";");
                for (let j = 0; j < paths.length; j++) {
                  if (paths[j] != "") {
                    _this.audioPath = paths[j];
                    _this.audioShow = true;
                    break;
                  }
                }
                // if (_this.audioPath == '') {
                //   _this.audioPath = res.rows[i].filePath
                //   _this.audioShow = true
                // }
              }
            }
            _this.photoList = pictures; //照片数组赋值
          }
        } else {
          Toast.fail(res.msg);
        }
      } catch (e) {
        Toast.clear();
        alert(JSON.stringify(e));
      }
    },
    // 获取当前时间
    getNowTime() {
      let dateTime;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf =
        new Date().getMinutes() < 10
          ? "0" + new Date().getMinutes()
          : new Date().getMinutes();
      let ss =
        new Date().getSeconds() < 10
          ? "0" + new Date().getSeconds()
          : new Date().getSeconds();
      dateTime = yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
      return dateTime;
    },
  },
};
</script>
<style>
body {
  background-color: White;
}

.pic {
  width: 100%;
  text-align: center;
}

.clickbtn {
  width: 1;
  margin: 5px 10px;
  line-height: 45px;
  border: 1px #ccc dashed;
  text-align: center;
}

.buttonColor {
  background-color: #ff9933;
  border-color: #ff9933;
}

.buttonColor2 {
  background-color: #1076c0;
  border-color: #1076c0;
}

.message {
  font-size: 15px;
  margin-top: 5px;
  margin-left: -10px;
  font-weight: bold;
}

.divStyle {
  border: 1px solid #dcdcdc;
  border-top-width: 3px;
  border-left-width: 3px;
  margin-left: 5px;
  margin-right: 4px;
  margin-top: 4px;
}

.pagination {
  position: fixed;
  bottom: 15px;
  width: 300px;
  margin-left: 10%;
  color: rgb(0, 0, 255);
  text-align: center;
}

.divMedia {
  margin-top: 0px;
  height: 230px;
  border: solid #dcdcdc;
  margin-left: 5px;
  margin-right: 15px;
  border-top-width: 4px;
  border-left-width: 4px;
  border-right-width: 1px;
  border-bottom-width: 1px;
}

.divMedia2 {
  margin-top: 0px;
  height: 190px;
  border: solid #dcdcdc;
  margin-left: 5px;
  margin-right: 15px;
  border-top-width: 4px;
  border-left-width: 4px;
  border-right-width: 1px;
  border-bottom-width: 1px;
}

.button {
  position: fixed;
  left: 5px;
  right: 5px;
  bottom: 24px;
  width: 100%;
  height: 30px;
  font-size: 12px;
}

.divMessage {
  margin-top: 0px;
  border: solid #dcdcdc;
  margin-left: 5px;
  margin-right: 15px;
  border-top-width: 4px;
  border-left-width: 4px;
  border-right-width: 1px;
  border-bottom-width: 1px;
}

.Field {
  font-weight: bold;
  font-size: 15px;
  color: #9c8e8e;
  height: 45px;
}

.textScroll {
  display: inline-block;
  position: fixed;
  top: 5rem;
  bottom: 4rem;
  overflow: scroll;
  right: 0;
  width: 100%;
  z-index: 1;
}
</style>
